package com.xiangge.number;

import java.math.BigInteger;

/**
 * @author xiangge
 * @version 1.0
 * @date 2025/4/14 11:39
 * @description   BigInteger 类
 *        描述： BigInteger 类用于表示一个任意精度的整数。它是Number 的子类。
 *              它用户表示long类型无表示的巨大整数
 *        构造方法：
 *              BigInteger(String s)
 *
 *         方法：
 *           BigInteger abs(BigInteger val)
 *           BigInteger add(BigInteger val)
 *           BigInteger subtract(BigInteger val)
 *           BigInteger multiply(BigInteger val)
 *           BigInteger divide(BigInteger val)
 *           BigInteger remainder(BigInteger val)
 *           BigInteger divideAndRemainder(BigInteger val)
 *
 */
public class NumberDemo5 {
    public static void main(String[] args) {
        BigInteger big1 = new BigInteger("100");
        BigInteger big2 = new BigInteger("3");
        BigInteger divide = big1.divide(big2);
        System.out.println("divide = " + divide);// 33
    }
    public static void main2(String[] args) {
        BigInteger big1 = new BigInteger("100");
        BigInteger big2 = new BigInteger("2");
        // 绝对值
        BigInteger big0 = big1.abs();
        System.out.println("big0 = " + big0); // 100
        // 加法
        BigInteger big3 = big1.add(big2);
        System.out.println("big3 = " + big3); // 102
        // 减法
        BigInteger big4 = big1.subtract(big2);
        System.out.println("big4 = " + big4); // 98
        // 乘法
        BigInteger big5 = big1.multiply(big2);
        System.out.println("big5 = " + big5); // 200
        // 除法
        BigInteger big6 = big1.divide(big2);
        System.out.println("big6 = " + big6); // 50
        // 取余
        BigInteger big7 = big1.remainder(big2);
        System.out.println("big7 = " + big7); // 0
        // 除法和取余
        BigInteger[] big8 = big1.divideAndRemainder(big2);
        System.out.println(big8.length); // 2
        System.out.println("big8[0] = " + big8[0]); // 50
        System.out.println("big8[1] = " + big8[1]); // 0
    }
    public static void main1(String[] args) {
        // long num = 12345678901234567890L;

        BigInteger num1 = new BigInteger("12345678901234567890L");


    }
}
